package com.eedi.framework.config.controller.sys;

import com.eedi.framework.config.service.HospitalConfigService;
import com.eedi.framework.common.pojo.CommonResult;
import com.eedi.framework.config.controller.sys.vo.app.HospitalAppCfgReq;
import com.eedi.framework.config.controller.sys.vo.app.HospitalAppCfgResp;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

import static com.eedi.framework.common.pojo.CommonResult.success;


/**
 * @author zybourn
 * @version 1.0
 * @description
 * @since 2024/3/13 19:22
 **/

//@Tag(name = "系统界面 - 系统应用配置管理")
//@RestController
//@RequestMapping("/app-cfg")
//@Validated
public class HospitalAppConfigController {

    @Resource
    private HospitalConfigService hospitalConfigService;
    /**
     * 保存应用配置
     * @param hospitalAppCfgReq
     * @return
     */
    @PostMapping("/save")
    public CommonResult<Boolean> saveAppCfg(@RequestBody @Validated HospitalAppCfgReq hospitalAppCfgReq) {
        hospitalConfigService.addOrUpdateHospitalAppConfig(hospitalAppCfgReq);
        return success(true);
    }

    /**
     * 删除应用配置
     * @param appType
     * @return
     */
    @GetMapping("/del")
    @Parameter(name = "appType", description = "应用类型", required = true)
    public CommonResult<Boolean> delAppCfg(Integer appType) {
        hospitalConfigService.delHospitalAppConfig(appType);
        return success(true);
    }

    /**
     * 查询所有应用配置
     * @return
     */
    @GetMapping("/list")
    public CommonResult<List<HospitalAppCfgResp>> listAppCfg() {
        return success(hospitalConfigService.getHospitalAppConfig());
    }
}
